<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/xhtml;charset=UTF-8"/>
<meta http-equiv="X-UA-Compatible" content="IE=9"/>
<meta name="generator" content="Doxygen 1.8.13"/>
<meta name="viewport" content="width=device-width, initial-scale=1"/>
<title>lwIP: src/core/ipv4/ip4.c File Reference</title>
<link href="tabs.css" rel="stylesheet" type="text/css"/>
<script type="text/javascript" src="jquery.js"></script>
<script type="text/javascript" src="dynsections.js"></script>
<link href="navtree.css" rel="stylesheet" type="text/css"/>
<script type="text/javascript" src="resize.js"></script>
<script type="text/javascript" src="navtreedata.js"></script>
<script type="text/javascript" src="navtree.js"></script>
<script type="text/javascript">
  $(document).ready(initResizable);
</script>
<link href="search/search.css" rel="stylesheet" type="text/css"/>
<script type="text/javascript" src="search/searchdata.js"></script>
<script type="text/javascript" src="search/search.js"></script>
<link href="doxygen.css" rel="stylesheet" type="text/css" />
</head>
<body>
<div id="top"><!-- do not remove this div, it is closed by doxygen! -->
<div id="titlearea">
<table cellspacing="0" cellpadding="0">
 <tbody>
 <tr style="height: 56px;">
  <td id="projectalign" style="padding-left: 0.5em;">
   <div id="projectname">lwIP
   &#160;<span id="projectnumber">2.1.2</span>
   </div>
   <div id="projectbrief">Lightweight IP stack</div>
  </td>
 </tr>
 </tbody>
</table>
</div>
<!-- end header part -->
<!-- Generated by Doxygen 1.8.13 -->
<script type="text/javascript">
var searchBox = new SearchBox("searchBox", "search",false,'Search');
</script>
<script type="text/javascript" src="menudata.js"></script>
<script type="text/javascript" src="menu.js"></script>
<script type="text/javascript">
$(function() {
  initMenu('',true,false,'search.php','Search');
  $(document).ready(function() { init_search(); });
});
</script>
<div id="main-nav"></div>
</div><!-- top -->
<div id="side-nav" class="ui-resizable side-nav-resizable">
  <div id="nav-tree">
    <div id="nav-tree-contents">
      <div id="nav-sync" class="sync"></div>
    </div>
  </div>
  <div id="splitbar" style="-moz-user-select:none;" 
       class="ui-resizable-handle">
  </div>
</div>
<script type="text/javascript">
$(document).ready(function(){initNavTree('ip4_8c.html','');});
</script>
<div id="doc-content">
<!-- window showing the filter options -->
<div id="MSearchSelectWindow"
     onmouseover="return searchBox.OnSearchSelectShow()"
     onmouseout="return searchBox.OnSearchSelectHide()"
     onkeydown="return searchBox.OnSearchSelectKey(event)">
</div>

<!-- iframe showing the search results (closed by default) -->
<div id="MSearchResultsWindow">
<iframe src="javascript:void(0)" frameborder="0" 
        name="MSearchResults" id="MSearchResults">
</iframe>
</div>

<div class="header">
  <div class="summary">
<a href="#define-members">Macros</a> &#124;
<a href="#func-members">Functions</a>  </div>
  <div class="headertitle">
<div class="title">ip4.c File Reference</div>  </div>
</div><!--header-->
<div class="contents">
<div class="textblock"><code>#include &quot;<a class="el" href="opt_8h.html">lwip/opt.h</a>&quot;</code><br />
<code>#include &quot;<a class="el" href="ip_8h.html">lwip/ip.h</a>&quot;</code><br />
<code>#include &quot;<a class="el" href="def_8h.html">lwip/def.h</a>&quot;</code><br />
<code>#include &quot;<a class="el" href="mem_8h.html">lwip/mem.h</a>&quot;</code><br />
<code>#include &quot;<a class="el" href="ip4__frag_8h.html">lwip/ip4_frag.h</a>&quot;</code><br />
<code>#include &quot;<a class="el" href="inet__chksum_8h.html">lwip/inet_chksum.h</a>&quot;</code><br />
<code>#include &quot;<a class="el" href="netif_8h.html">lwip/netif.h</a>&quot;</code><br />
<code>#include &quot;<a class="el" href="icmp_8h.html">lwip/icmp.h</a>&quot;</code><br />
<code>#include &quot;<a class="el" href="igmp_8h.html">lwip/igmp.h</a>&quot;</code><br />
<code>#include &quot;<a class="el" href="raw__priv_8h.html">lwip/priv/raw_priv.h</a>&quot;</code><br />
<code>#include &quot;<a class="el" href="udp_8h.html">lwip/udp.h</a>&quot;</code><br />
<code>#include &quot;<a class="el" href="tcp__priv_8h.html">lwip/priv/tcp_priv.h</a>&quot;</code><br />
<code>#include &quot;<a class="el" href="autoip_8h.html">lwip/autoip.h</a>&quot;</code><br />
<code>#include &quot;<a class="el" href="stats_8h.html">lwip/stats.h</a>&quot;</code><br />
<code>#include &quot;<a class="el" href="iana_8h.html">lwip/prot/iana.h</a>&quot;</code><br />
<code>#include &lt;string.h&gt;</code><br />
<code>#include &quot;path/to/my/lwip_hooks.h&quot;</code><br />
</div><table class="memberdecls">
<tr class="heading"><td colspan="2"><h2 class="groupheader"><a name="define-members"></a>
Macros</h2></td></tr>
<tr class="memitem:a9652ce304f893f6245c6ba9daea0a30f"><td class="memItemLeft" align="right" valign="top">#define&#160;</td><td class="memItemRight" valign="bottom"><a class="el" href="ip4_8c.html#a9652ce304f893f6245c6ba9daea0a30f">LWIP_INLINE_IP_CHKSUM</a>&#160;&#160;&#160;1</td></tr>
<tr class="separator:a9652ce304f893f6245c6ba9daea0a30f"><td class="memSeparator" colspan="2">&#160;</td></tr>
<tr class="memitem:a185c7d6380711847105430931692b267"><td class="memItemLeft" align="right" valign="top">#define&#160;</td><td class="memItemRight" valign="bottom"><a class="el" href="ip4_8c.html#a185c7d6380711847105430931692b267">IP_ACCEPT_LINK_LAYER_ADDRESSED_PORT</a>(port)&#160;&#160;&#160;((port) == PP_NTOHS(<a class="el" href="group__iana.html#ggac9396d90585e49e9a287179bf5aa9ba0a9fcae1f16758e1ac35dab343fc897f40">LWIP_IANA_PORT_DHCP_CLIENT</a>))</td></tr>
<tr class="separator:a185c7d6380711847105430931692b267"><td class="memSeparator" colspan="2">&#160;</td></tr>
</table><table class="memberdecls">
<tr class="heading"><td colspan="2"><h2 class="groupheader"><a name="func-members"></a>
Functions</h2></td></tr>
<tr class="memitem:ga6ae67c86aa82dccac5df81d93de00420"><td class="memItemLeft" align="right" valign="top">void&#160;</td><td class="memItemRight" valign="bottom"><a class="el" href="group__ip4.html#ga6ae67c86aa82dccac5df81d93de00420">ip4_set_default_multicast_netif</a> (struct <a class="el" href="structnetif.html">netif</a> *default_multicast_netif)</td></tr>
<tr class="separator:ga6ae67c86aa82dccac5df81d93de00420"><td class="memSeparator" colspan="2">&#160;</td></tr>
<tr class="memitem:ab615a9ca8fdd99e697f52506fc440fba"><td class="memItemLeft" align="right" valign="top">struct <a class="el" href="structnetif.html">netif</a> *&#160;</td><td class="memItemRight" valign="bottom"><a class="el" href="ip4_8c.html#ab615a9ca8fdd99e697f52506fc440fba">ip4_route_src</a> (const <a class="el" href="ip4__addr_8h.html#a3d3b45daffbc15d65da236e31e621b7e">ip4_addr_t</a> *src, const <a class="el" href="ip4__addr_8h.html#a3d3b45daffbc15d65da236e31e621b7e">ip4_addr_t</a> *dest)</td></tr>
<tr class="separator:ab615a9ca8fdd99e697f52506fc440fba"><td class="memSeparator" colspan="2">&#160;</td></tr>
<tr class="memitem:ac659f675356cfc1d4d13884946347e47"><td class="memItemLeft" align="right" valign="top">struct <a class="el" href="structnetif.html">netif</a> *&#160;</td><td class="memItemRight" valign="bottom"><a class="el" href="ip4_8c.html#ac659f675356cfc1d4d13884946347e47">ip4_route</a> (const <a class="el" href="ip4__addr_8h.html#a3d3b45daffbc15d65da236e31e621b7e">ip4_addr_t</a> *dest)</td></tr>
<tr class="separator:ac659f675356cfc1d4d13884946347e47"><td class="memSeparator" colspan="2">&#160;</td></tr>
<tr class="memitem:aff1f784c9f05f3d79cc1a921d840501b"><td class="memItemLeft" align="right" valign="top"><a class="el" href="group__infrastructure__errors.html#gaf02d9da80fd66b4f986d2c53d7231ddb">err_t</a>&#160;</td><td class="memItemRight" valign="bottom"><a class="el" href="ip4_8c.html#aff1f784c9f05f3d79cc1a921d840501b">ip4_input</a> (struct <a class="el" href="structpbuf.html">pbuf</a> *p, struct <a class="el" href="structnetif.html">netif</a> *inp)</td></tr>
<tr class="separator:aff1f784c9f05f3d79cc1a921d840501b"><td class="memSeparator" colspan="2">&#160;</td></tr>
<tr class="memitem:ab220bc4ce4f48bdbba447358b3594917"><td class="memItemLeft" align="right" valign="top"><a class="el" href="group__infrastructure__errors.html#gaf02d9da80fd66b4f986d2c53d7231ddb">err_t</a>&#160;</td><td class="memItemRight" valign="bottom"><a class="el" href="ip4_8c.html#ab220bc4ce4f48bdbba447358b3594917">ip4_output_if</a> (struct <a class="el" href="structpbuf.html">pbuf</a> *p, const <a class="el" href="ip4__addr_8h.html#a3d3b45daffbc15d65da236e31e621b7e">ip4_addr_t</a> *src, const <a class="el" href="ip4__addr_8h.html#a3d3b45daffbc15d65da236e31e621b7e">ip4_addr_t</a> *dest, u8_t ttl, u8_t tos, u8_t proto, struct <a class="el" href="structnetif.html">netif</a> *<a class="el" href="structnetif.html">netif</a>)</td></tr>
<tr class="separator:ab220bc4ce4f48bdbba447358b3594917"><td class="memSeparator" colspan="2">&#160;</td></tr>
<tr class="memitem:a0d912e400875396792a12ea443ecc1cf"><td class="memItemLeft" align="right" valign="top"><a class="el" href="group__infrastructure__errors.html#gaf02d9da80fd66b4f986d2c53d7231ddb">err_t</a>&#160;</td><td class="memItemRight" valign="bottom"><a class="el" href="ip4_8c.html#a0d912e400875396792a12ea443ecc1cf">ip4_output_if_opt</a> (struct <a class="el" href="structpbuf.html">pbuf</a> *p, const <a class="el" href="ip4__addr_8h.html#a3d3b45daffbc15d65da236e31e621b7e">ip4_addr_t</a> *src, const <a class="el" href="ip4__addr_8h.html#a3d3b45daffbc15d65da236e31e621b7e">ip4_addr_t</a> *dest, u8_t ttl, u8_t tos, u8_t proto, struct <a class="el" href="structnetif.html">netif</a> *<a class="el" href="structnetif.html">netif</a>, void *ip_options, u16_t optlen)</td></tr>
<tr class="separator:a0d912e400875396792a12ea443ecc1cf"><td class="memSeparator" colspan="2">&#160;</td></tr>
<tr class="memitem:a2943d118873e9eb1d8296e04a6740db7"><td class="memItemLeft" align="right" valign="top"><a class="el" href="group__infrastructure__errors.html#gaf02d9da80fd66b4f986d2c53d7231ddb">err_t</a>&#160;</td><td class="memItemRight" valign="bottom"><a class="el" href="ip4_8c.html#a2943d118873e9eb1d8296e04a6740db7">ip4_output_if_src</a> (struct <a class="el" href="structpbuf.html">pbuf</a> *p, const <a class="el" href="ip4__addr_8h.html#a3d3b45daffbc15d65da236e31e621b7e">ip4_addr_t</a> *src, const <a class="el" href="ip4__addr_8h.html#a3d3b45daffbc15d65da236e31e621b7e">ip4_addr_t</a> *dest, u8_t ttl, u8_t tos, u8_t proto, struct <a class="el" href="structnetif.html">netif</a> *<a class="el" href="structnetif.html">netif</a>)</td></tr>
<tr class="separator:a2943d118873e9eb1d8296e04a6740db7"><td class="memSeparator" colspan="2">&#160;</td></tr>
<tr class="memitem:accd56b095730de4ad56728bfcb349940"><td class="memItemLeft" align="right" valign="top"><a class="el" href="group__infrastructure__errors.html#gaf02d9da80fd66b4f986d2c53d7231ddb">err_t</a>&#160;</td><td class="memItemRight" valign="bottom"><a class="el" href="ip4_8c.html#accd56b095730de4ad56728bfcb349940">ip4_output_if_opt_src</a> (struct <a class="el" href="structpbuf.html">pbuf</a> *p, const <a class="el" href="ip4__addr_8h.html#a3d3b45daffbc15d65da236e31e621b7e">ip4_addr_t</a> *src, const <a class="el" href="ip4__addr_8h.html#a3d3b45daffbc15d65da236e31e621b7e">ip4_addr_t</a> *dest, u8_t ttl, u8_t tos, u8_t proto, struct <a class="el" href="structnetif.html">netif</a> *<a class="el" href="structnetif.html">netif</a>, void *ip_options, u16_t optlen)</td></tr>
<tr class="separator:accd56b095730de4ad56728bfcb349940"><td class="memSeparator" colspan="2">&#160;</td></tr>
<tr class="memitem:ac87d296205eb5ac04058e609672d4ba8"><td class="memItemLeft" align="right" valign="top"><a class="el" href="group__infrastructure__errors.html#gaf02d9da80fd66b4f986d2c53d7231ddb">err_t</a>&#160;</td><td class="memItemRight" valign="bottom"><a class="el" href="ip4_8c.html#ac87d296205eb5ac04058e609672d4ba8">ip4_output</a> (struct <a class="el" href="structpbuf.html">pbuf</a> *p, const <a class="el" href="ip4__addr_8h.html#a3d3b45daffbc15d65da236e31e621b7e">ip4_addr_t</a> *src, const <a class="el" href="ip4__addr_8h.html#a3d3b45daffbc15d65da236e31e621b7e">ip4_addr_t</a> *dest, u8_t ttl, u8_t tos, u8_t proto)</td></tr>
<tr class="separator:ac87d296205eb5ac04058e609672d4ba8"><td class="memSeparator" colspan="2">&#160;</td></tr>
</table>
<a name="details" id="details"></a><h2 class="groupheader">Detailed Description</h2>
<div class="textblock"><p>This is the IPv4 layer implementation for incoming and outgoing IP traffic.</p>
<dl class="section see"><dt>See also</dt><dd>ip_frag.c </dd></dl>
</div><h2 class="groupheader">Macro Definition Documentation</h2>
<a id="a185c7d6380711847105430931692b267"></a>
<h2 class="memtitle"><span class="permalink"><a href="#a185c7d6380711847105430931692b267">&#9670;&nbsp;</a></span>IP_ACCEPT_LINK_LAYER_ADDRESSED_PORT</h2>

<div class="memitem">
<div class="memproto">
      <table class="memname">
        <tr>
          <td class="memname">#define IP_ACCEPT_LINK_LAYER_ADDRESSED_PORT</td>
          <td>(</td>
          <td class="paramtype">&#160;</td>
          <td class="paramname">port</td><td>)</td>
          <td>&#160;&#160;&#160;((port) == PP_NTOHS(<a class="el" href="group__iana.html#ggac9396d90585e49e9a287179bf5aa9ba0a9fcae1f16758e1ac35dab343fc897f40">LWIP_IANA_PORT_DHCP_CLIENT</a>))</td>
        </tr>
      </table>
</div><div class="memdoc">
<p>Some defines for DHCP to let link-layer-addressed packets through while the netif is down. To use this in your own application/protocol, define LWIP_IP_ACCEPT_UDP_PORT(port) to return 1 if the port is accepted and 0 if the port is not accepted. </p>

</div>
</div>
<a id="a9652ce304f893f6245c6ba9daea0a30f"></a>
<h2 class="memtitle"><span class="permalink"><a href="#a9652ce304f893f6245c6ba9daea0a30f">&#9670;&nbsp;</a></span>LWIP_INLINE_IP_CHKSUM</h2>

<div class="memitem">
<div class="memproto">
      <table class="memname">
        <tr>
          <td class="memname">#define LWIP_INLINE_IP_CHKSUM&#160;&#160;&#160;1</td>
        </tr>
      </table>
</div><div class="memdoc">
<p>Set this to 0 in the rare case of wanting to call an extra function to generate the IP checksum (in contrast to calculating it on-the-fly). </p>

</div>
</div>
<h2 class="groupheader">Function Documentation</h2>
<a id="aff1f784c9f05f3d79cc1a921d840501b"></a>
<h2 class="memtitle"><span class="permalink"><a href="#aff1f784c9f05f3d79cc1a921d840501b">&#9670;&nbsp;</a></span>ip4_input()</h2>

<div class="memitem">
<div class="memproto">
      <table class="memname">
        <tr>
          <td class="memname"><a class="el" href="group__infrastructure__errors.html#gaf02d9da80fd66b4f986d2c53d7231ddb">err_t</a> ip4_input </td>
          <td>(</td>
          <td class="paramtype">struct <a class="el" href="structpbuf.html">pbuf</a> *&#160;</td>
          <td class="paramname"><em>p</em>, </td>
        </tr>
        <tr>
          <td class="paramkey"></td>
          <td></td>
          <td class="paramtype">struct <a class="el" href="structnetif.html">netif</a> *&#160;</td>
          <td class="paramname"><em>inp</em>&#160;</td>
        </tr>
        <tr>
          <td></td>
          <td>)</td>
          <td></td><td></td>
        </tr>
      </table>
</div><div class="memdoc">
<p>This function is called by the network interface device driver when an IP packet is received. The function does the basic checks of the IP header such as packet size being at least larger than the header size etc. If the packet was not destined for us, the packet is forwarded (using ip_forward). The IP checksum is always checked.</p>
<p>Finally, the packet is sent to the upper layer protocol input function.</p>
<dl class="params"><dt>Parameters</dt><dd>
  <table class="params">
    <tr><td class="paramname">p</td><td>the received IP packet (p-&gt;payload points to IP header) </td></tr>
    <tr><td class="paramname">inp</td><td>the netif on which this packet was received </td></tr>
  </table>
  </dd>
</dl>
<dl class="section return"><dt>Returns</dt><dd>ERR_OK if the packet was processed (could return ERR_* if it wasn't processed, but currently always returns ERR_OK) </dd></dl>

</div>
</div>
<a id="ac87d296205eb5ac04058e609672d4ba8"></a>
<h2 class="memtitle"><span class="permalink"><a href="#ac87d296205eb5ac04058e609672d4ba8">&#9670;&nbsp;</a></span>ip4_output()</h2>

<div class="memitem">
<div class="memproto">
      <table class="memname">
        <tr>
          <td class="memname"><a class="el" href="group__infrastructure__errors.html#gaf02d9da80fd66b4f986d2c53d7231ddb">err_t</a> ip4_output </td>
          <td>(</td>
          <td class="paramtype">struct <a class="el" href="structpbuf.html">pbuf</a> *&#160;</td>
          <td class="paramname"><em>p</em>, </td>
        </tr>
        <tr>
          <td class="paramkey"></td>
          <td></td>
          <td class="paramtype">const <a class="el" href="ip4__addr_8h.html#a3d3b45daffbc15d65da236e31e621b7e">ip4_addr_t</a> *&#160;</td>
          <td class="paramname"><em>src</em>, </td>
        </tr>
        <tr>
          <td class="paramkey"></td>
          <td></td>
          <td class="paramtype">const <a class="el" href="ip4__addr_8h.html#a3d3b45daffbc15d65da236e31e621b7e">ip4_addr_t</a> *&#160;</td>
          <td class="paramname"><em>dest</em>, </td>
        </tr>
        <tr>
          <td class="paramkey"></td>
          <td></td>
          <td class="paramtype">u8_t&#160;</td>
          <td class="paramname"><em>ttl</em>, </td>
        </tr>
        <tr>
          <td class="paramkey"></td>
          <td></td>
          <td class="paramtype">u8_t&#160;</td>
          <td class="paramname"><em>tos</em>, </td>
        </tr>
        <tr>
          <td class="paramkey"></td>
          <td></td>
          <td class="paramtype">u8_t&#160;</td>
          <td class="paramname"><em>proto</em>&#160;</td>
        </tr>
        <tr>
          <td></td>
          <td>)</td>
          <td></td><td></td>
        </tr>
      </table>
</div><div class="memdoc">
<p>Simple interface to ip_output_if. It finds the outgoing network interface and calls upon ip_output_if to do the actual work.</p>
<dl class="params"><dt>Parameters</dt><dd>
  <table class="params">
    <tr><td class="paramname">p</td><td>the packet to send (p-&gt;payload points to the data, e.g. next protocol header; if dest == LWIP_IP_HDRINCL, p already includes an IP header and p-&gt;payload points to that IP header) </td></tr>
    <tr><td class="paramname">src</td><td>the source IP address to send from (if src == IP4_ADDR_ANY, the IP address of the netif used to send is used as source address) </td></tr>
    <tr><td class="paramname">dest</td><td>the destination IP address to send the packet to </td></tr>
    <tr><td class="paramname">ttl</td><td>the TTL value to be set in the IP header </td></tr>
    <tr><td class="paramname">tos</td><td>the TOS value to be set in the IP header </td></tr>
    <tr><td class="paramname">proto</td><td>the PROTOCOL to be set in the IP header</td></tr>
  </table>
  </dd>
</dl>
<dl class="section return"><dt>Returns</dt><dd>ERR_RTE if no route is found see <a class="el" href="group__ip.html#ga51cd772c3f6fca7c0363dca1fce7b250">ip_output_if()</a> for more return values </dd></dl>

</div>
</div>
<a id="ab220bc4ce4f48bdbba447358b3594917"></a>
<h2 class="memtitle"><span class="permalink"><a href="#ab220bc4ce4f48bdbba447358b3594917">&#9670;&nbsp;</a></span>ip4_output_if()</h2>

<div class="memitem">
<div class="memproto">
      <table class="memname">
        <tr>
          <td class="memname"><a class="el" href="group__infrastructure__errors.html#gaf02d9da80fd66b4f986d2c53d7231ddb">err_t</a> ip4_output_if </td>
          <td>(</td>
          <td class="paramtype">struct <a class="el" href="structpbuf.html">pbuf</a> *&#160;</td>
          <td class="paramname"><em>p</em>, </td>
        </tr>
        <tr>
          <td class="paramkey"></td>
          <td></td>
          <td class="paramtype">const <a class="el" href="ip4__addr_8h.html#a3d3b45daffbc15d65da236e31e621b7e">ip4_addr_t</a> *&#160;</td>
          <td class="paramname"><em>src</em>, </td>
        </tr>
        <tr>
          <td class="paramkey"></td>
          <td></td>
          <td class="paramtype">const <a class="el" href="ip4__addr_8h.html#a3d3b45daffbc15d65da236e31e621b7e">ip4_addr_t</a> *&#160;</td>
          <td class="paramname"><em>dest</em>, </td>
        </tr>
        <tr>
          <td class="paramkey"></td>
          <td></td>
          <td class="paramtype">u8_t&#160;</td>
          <td class="paramname"><em>ttl</em>, </td>
        </tr>
        <tr>
          <td class="paramkey"></td>
          <td></td>
          <td class="paramtype">u8_t&#160;</td>
          <td class="paramname"><em>tos</em>, </td>
        </tr>
        <tr>
          <td class="paramkey"></td>
          <td></td>
          <td class="paramtype">u8_t&#160;</td>
          <td class="paramname"><em>proto</em>, </td>
        </tr>
        <tr>
          <td class="paramkey"></td>
          <td></td>
          <td class="paramtype">struct <a class="el" href="structnetif.html">netif</a> *&#160;</td>
          <td class="paramname"><em>netif</em>&#160;</td>
        </tr>
        <tr>
          <td></td>
          <td>)</td>
          <td></td><td></td>
        </tr>
      </table>
</div><div class="memdoc">
<p>Sends an IP packet on a network interface. This function constructs the IP header and calculates the IP header checksum. If the source IP address is NULL, the IP address of the outgoing network interface is filled in as source address. If the destination IP address is LWIP_IP_HDRINCL, p is assumed to already include an IP header and p-&gt;payload points to it instead of the data.</p>
<dl class="params"><dt>Parameters</dt><dd>
  <table class="params">
    <tr><td class="paramname">p</td><td>the packet to send (p-&gt;payload points to the data, e.g. next protocol header; if dest == LWIP_IP_HDRINCL, p already includes an IP header and p-&gt;payload points to that IP header) </td></tr>
    <tr><td class="paramname">src</td><td>the source IP address to send from (if src == IP4_ADDR_ANY, the IP address of the netif used to send is used as source address) </td></tr>
    <tr><td class="paramname">dest</td><td>the destination IP address to send the packet to </td></tr>
    <tr><td class="paramname">ttl</td><td>the TTL value to be set in the IP header </td></tr>
    <tr><td class="paramname">tos</td><td>the TOS value to be set in the IP header </td></tr>
    <tr><td class="paramname">proto</td><td>the PROTOCOL to be set in the IP header </td></tr>
    <tr><td class="paramname">netif</td><td>the netif on which to send this packet </td></tr>
  </table>
  </dd>
</dl>
<dl class="section return"><dt>Returns</dt><dd>ERR_OK if the packet was sent OK ERR_BUF if p doesn't have enough space for IP/LINK headers returns errors returned by netif-&gt;output</dd></dl>
<dl class="section note"><dt>Note</dt><dd>ip_id: RFC791 "some host may be able to simply use
 unique identifiers independent of destination" </dd></dl>

</div>
</div>
<a id="a0d912e400875396792a12ea443ecc1cf"></a>
<h2 class="memtitle"><span class="permalink"><a href="#a0d912e400875396792a12ea443ecc1cf">&#9670;&nbsp;</a></span>ip4_output_if_opt()</h2>

<div class="memitem">
<div class="memproto">
      <table class="memname">
        <tr>
          <td class="memname"><a class="el" href="group__infrastructure__errors.html#gaf02d9da80fd66b4f986d2c53d7231ddb">err_t</a> ip4_output_if_opt </td>
          <td>(</td>
          <td class="paramtype">struct <a class="el" href="structpbuf.html">pbuf</a> *&#160;</td>
          <td class="paramname"><em>p</em>, </td>
        </tr>
        <tr>
          <td class="paramkey"></td>
          <td></td>
          <td class="paramtype">const <a class="el" href="ip4__addr_8h.html#a3d3b45daffbc15d65da236e31e621b7e">ip4_addr_t</a> *&#160;</td>
          <td class="paramname"><em>src</em>, </td>
        </tr>
        <tr>
          <td class="paramkey"></td>
          <td></td>
          <td class="paramtype">const <a class="el" href="ip4__addr_8h.html#a3d3b45daffbc15d65da236e31e621b7e">ip4_addr_t</a> *&#160;</td>
          <td class="paramname"><em>dest</em>, </td>
        </tr>
        <tr>
          <td class="paramkey"></td>
          <td></td>
          <td class="paramtype">u8_t&#160;</td>
          <td class="paramname"><em>ttl</em>, </td>
        </tr>
        <tr>
          <td class="paramkey"></td>
          <td></td>
          <td class="paramtype">u8_t&#160;</td>
          <td class="paramname"><em>tos</em>, </td>
        </tr>
        <tr>
          <td class="paramkey"></td>
          <td></td>
          <td class="paramtype">u8_t&#160;</td>
          <td class="paramname"><em>proto</em>, </td>
        </tr>
        <tr>
          <td class="paramkey"></td>
          <td></td>
          <td class="paramtype">struct <a class="el" href="structnetif.html">netif</a> *&#160;</td>
          <td class="paramname"><em>netif</em>, </td>
        </tr>
        <tr>
          <td class="paramkey"></td>
          <td></td>
          <td class="paramtype">void *&#160;</td>
          <td class="paramname"><em>ip_options</em>, </td>
        </tr>
        <tr>
          <td class="paramkey"></td>
          <td></td>
          <td class="paramtype">u16_t&#160;</td>
          <td class="paramname"><em>optlen</em>&#160;</td>
        </tr>
        <tr>
          <td></td>
          <td>)</td>
          <td></td><td></td>
        </tr>
      </table>
</div><div class="memdoc">
<p>Same as <a class="el" href="group__ip.html#ga51cd772c3f6fca7c0363dca1fce7b250">ip_output_if()</a> but with the possibility to include IP options:</p>
<p>@ param ip_options pointer to the IP options, copied into the IP header @ param optlen length of ip_options </p>

</div>
</div>
<a id="accd56b095730de4ad56728bfcb349940"></a>
<h2 class="memtitle"><span class="permalink"><a href="#accd56b095730de4ad56728bfcb349940">&#9670;&nbsp;</a></span>ip4_output_if_opt_src()</h2>

<div class="memitem">
<div class="memproto">
      <table class="memname">
        <tr>
          <td class="memname"><a class="el" href="group__infrastructure__errors.html#gaf02d9da80fd66b4f986d2c53d7231ddb">err_t</a> ip4_output_if_opt_src </td>
          <td>(</td>
          <td class="paramtype">struct <a class="el" href="structpbuf.html">pbuf</a> *&#160;</td>
          <td class="paramname"><em>p</em>, </td>
        </tr>
        <tr>
          <td class="paramkey"></td>
          <td></td>
          <td class="paramtype">const <a class="el" href="ip4__addr_8h.html#a3d3b45daffbc15d65da236e31e621b7e">ip4_addr_t</a> *&#160;</td>
          <td class="paramname"><em>src</em>, </td>
        </tr>
        <tr>
          <td class="paramkey"></td>
          <td></td>
          <td class="paramtype">const <a class="el" href="ip4__addr_8h.html#a3d3b45daffbc15d65da236e31e621b7e">ip4_addr_t</a> *&#160;</td>
          <td class="paramname"><em>dest</em>, </td>
        </tr>
        <tr>
          <td class="paramkey"></td>
          <td></td>
          <td class="paramtype">u8_t&#160;</td>
          <td class="paramname"><em>ttl</em>, </td>
        </tr>
        <tr>
          <td class="paramkey"></td>
          <td></td>
          <td class="paramtype">u8_t&#160;</td>
          <td class="paramname"><em>tos</em>, </td>
        </tr>
        <tr>
          <td class="paramkey"></td>
          <td></td>
          <td class="paramtype">u8_t&#160;</td>
          <td class="paramname"><em>proto</em>, </td>
        </tr>
        <tr>
          <td class="paramkey"></td>
          <td></td>
          <td class="paramtype">struct <a class="el" href="structnetif.html">netif</a> *&#160;</td>
          <td class="paramname"><em>netif</em>, </td>
        </tr>
        <tr>
          <td class="paramkey"></td>
          <td></td>
          <td class="paramtype">void *&#160;</td>
          <td class="paramname"><em>ip_options</em>, </td>
        </tr>
        <tr>
          <td class="paramkey"></td>
          <td></td>
          <td class="paramtype">u16_t&#160;</td>
          <td class="paramname"><em>optlen</em>&#160;</td>
        </tr>
        <tr>
          <td></td>
          <td>)</td>
          <td></td><td></td>
        </tr>
      </table>
</div><div class="memdoc">
<p>Same as ip_output_if_opt() but 'src' address is not replaced by netif address when it is 'any'. </p>

</div>
</div>
<a id="a2943d118873e9eb1d8296e04a6740db7"></a>
<h2 class="memtitle"><span class="permalink"><a href="#a2943d118873e9eb1d8296e04a6740db7">&#9670;&nbsp;</a></span>ip4_output_if_src()</h2>

<div class="memitem">
<div class="memproto">
      <table class="memname">
        <tr>
          <td class="memname"><a class="el" href="group__infrastructure__errors.html#gaf02d9da80fd66b4f986d2c53d7231ddb">err_t</a> ip4_output_if_src </td>
          <td>(</td>
          <td class="paramtype">struct <a class="el" href="structpbuf.html">pbuf</a> *&#160;</td>
          <td class="paramname"><em>p</em>, </td>
        </tr>
        <tr>
          <td class="paramkey"></td>
          <td></td>
          <td class="paramtype">const <a class="el" href="ip4__addr_8h.html#a3d3b45daffbc15d65da236e31e621b7e">ip4_addr_t</a> *&#160;</td>
          <td class="paramname"><em>src</em>, </td>
        </tr>
        <tr>
          <td class="paramkey"></td>
          <td></td>
          <td class="paramtype">const <a class="el" href="ip4__addr_8h.html#a3d3b45daffbc15d65da236e31e621b7e">ip4_addr_t</a> *&#160;</td>
          <td class="paramname"><em>dest</em>, </td>
        </tr>
        <tr>
          <td class="paramkey"></td>
          <td></td>
          <td class="paramtype">u8_t&#160;</td>
          <td class="paramname"><em>ttl</em>, </td>
        </tr>
        <tr>
          <td class="paramkey"></td>
          <td></td>
          <td class="paramtype">u8_t&#160;</td>
          <td class="paramname"><em>tos</em>, </td>
        </tr>
        <tr>
          <td class="paramkey"></td>
          <td></td>
          <td class="paramtype">u8_t&#160;</td>
          <td class="paramname"><em>proto</em>, </td>
        </tr>
        <tr>
          <td class="paramkey"></td>
          <td></td>
          <td class="paramtype">struct <a class="el" href="structnetif.html">netif</a> *&#160;</td>
          <td class="paramname"><em>netif</em>&#160;</td>
        </tr>
        <tr>
          <td></td>
          <td>)</td>
          <td></td><td></td>
        </tr>
      </table>
</div><div class="memdoc">
<p>Same as <a class="el" href="group__ip.html#ga51cd772c3f6fca7c0363dca1fce7b250">ip_output_if()</a> but 'src' address is not replaced by netif address when it is 'any'. </p>

</div>
</div>
<a id="ac659f675356cfc1d4d13884946347e47"></a>
<h2 class="memtitle"><span class="permalink"><a href="#ac659f675356cfc1d4d13884946347e47">&#9670;&nbsp;</a></span>ip4_route()</h2>

<div class="memitem">
<div class="memproto">
      <table class="memname">
        <tr>
          <td class="memname">struct <a class="el" href="structnetif.html">netif</a>* ip4_route </td>
          <td>(</td>
          <td class="paramtype">const <a class="el" href="ip4__addr_8h.html#a3d3b45daffbc15d65da236e31e621b7e">ip4_addr_t</a> *&#160;</td>
          <td class="paramname"><em>dest</em></td><td>)</td>
          <td></td>
        </tr>
      </table>
</div><div class="memdoc">
<p>Finds the appropriate network interface for a given IP address. It searches the list of network interfaces linearly. A match is found if the masked IP address of the network interface equals the masked IP address given to the function.</p>
<dl class="params"><dt>Parameters</dt><dd>
  <table class="params">
    <tr><td class="paramname">dest</td><td>the destination IP address for which to find the route </td></tr>
  </table>
  </dd>
</dl>
<dl class="section return"><dt>Returns</dt><dd>the netif on which to send to reach dest </dd></dl>

</div>
</div>
<a id="ab615a9ca8fdd99e697f52506fc440fba"></a>
<h2 class="memtitle"><span class="permalink"><a href="#ab615a9ca8fdd99e697f52506fc440fba">&#9670;&nbsp;</a></span>ip4_route_src()</h2>

<div class="memitem">
<div class="memproto">
      <table class="memname">
        <tr>
          <td class="memname">struct <a class="el" href="structnetif.html">netif</a>* ip4_route_src </td>
          <td>(</td>
          <td class="paramtype">const <a class="el" href="ip4__addr_8h.html#a3d3b45daffbc15d65da236e31e621b7e">ip4_addr_t</a> *&#160;</td>
          <td class="paramname"><em>src</em>, </td>
        </tr>
        <tr>
          <td class="paramkey"></td>
          <td></td>
          <td class="paramtype">const <a class="el" href="ip4__addr_8h.html#a3d3b45daffbc15d65da236e31e621b7e">ip4_addr_t</a> *&#160;</td>
          <td class="paramname"><em>dest</em>&#160;</td>
        </tr>
        <tr>
          <td></td>
          <td>)</td>
          <td></td><td></td>
        </tr>
      </table>
</div><div class="memdoc">
<p>Source based IPv4 routing must be fully implemented in <a class="el" href="group__lwip__opts__hooks.html#gaa410d9cbe1d4fa4c8a7f49af7b501024">LWIP_HOOK_IP4_ROUTE_SRC()</a>. This function only provides the parameters. </p>

</div>
</div>
</div><!-- contents -->
</div><!-- doc-content -->
<!-- start footer part -->
<div id="nav-path" class="navpath"><!-- id is needed for treeview function! -->
  <ul>
    <li class="navelem"><a class="el" href="dir_68267d1309a1af8e8297ef4c3efbcdba.html">src</a></li><li class="navelem"><a class="el" href="dir_aebb8dcc11953d78e620bbef0b9e2183.html">core</a></li><li class="navelem"><a class="el" href="dir_a32e111ee6805cfc63488fd2d37f2390.html">ipv4</a></li><li class="navelem"><a class="el" href="ip4_8c.html">ip4.c</a></li>
    <li class="footer">Generated by
    <a href="http://www.doxygen.org/index.html">
    <img class="footer" src="doxygen.png" alt="doxygen"/></a> 1.8.13 </li>
  </ul>
</div>
</body>
</html>
